package com.air.repo.design.pattern.singleton;

import java.io.ObjectStreamException;
import java.io.Serializable;

/**
 * Place Function on Here:
 *
 * @author yh 2018/7/12 13:36
 * @since: Jdk 1.8
 */
public class Singleton5 implements Serializable{

    private  static class Singleton4Holder {
        public static final Singleton5 instance=new Singleton5();
    }

    private Singleton5()  {}

    // 防止反序列化获取多个对象的漏洞
//    private Object readResolve() throws ObjectStreamException {
//        return Singleton4Holder.instance;
//    }


    public static Singleton5 getInstance(){
        return Singleton4Holder.instance;
    }

}
